/*
 * @Description:
 * @Author: py
 * @Date: 2024-08-09
 */
import type { PlusColumn } from 'plus-pro-components'

import { useDicts } from './use-dicts'

const { getDictOptions } = useDicts()

const aSaleStatusOptions = getDictOptions('oAfterSaleStatus')
const orderStatusOptions = getDictOptions('oOrderStatus', true)

export function useForm() {
    const schema: PlusColumn[] = [
        {
            colProps: {
                span: 6,
            },
            label: '商品名称',
            prop: 'goodsName',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 6,
            },
            label: '订单号',
            prop: 'orderCode',
            valueType: 'copy',
        },
        {
            colProps: {
                span: 7,
            },
            fieldProps: {
                endPlaceholder: '结束日期',
                format: 'YYYY-MM-DD',
                startPlaceholder: '开始日期',
                type: 'daterange',
                valueFormat: 'YYYY-MM-DD',
            },
            label: '下单日期',
            prop: 'orderDate',
            valueType: 'date-picker',
        },
        {
            colProps: {
                span: 5,
            },
            label: '售后状态',
            options: aSaleStatusOptions,
            prop: 'orderAfterSaleStatus',
            valueType: 'select',
        },
        {
            label: '订单状态',
            options: orderStatusOptions,
            prop: 'orderStatus',
            valueType: 'radio',
        },
    ]

    const state = {
        goodsName: '',
        orderAfterSaleStatus: '',
        orderCode: '',
        orderDate: null,
        orderStatus: '',
    }
    const form = ref({
        ...state,
    })
    return { form, schema, state }
}
